<?php
namespace app\controller;

use app\BaseController;
use app\common\JwpLog;
use app\manager\RedisDriver;
use app\manager\RedisInstance;
use think\Exception;
use think\facade\Db;
use think\facade\Log;
use think\facade\View;
use Throwable;

class Index extends Base
{
    public function abc(){

        if (post('id')){

            //更新
        }

        $user = Db::find();
        $arr = [
            ['id'=>"1","name"=>"aaaa"],
            ['id'=>"2","name"=>"bbb"],
            ['id'=>"3","name"=>"bbb"],
        ];
        View::assign('arr',$arr);
        View::assign('name','ThinkPHP');
        return View::fetch("abc");
    }
    public function index()
    {
        JwpLog::info("hello");
        JwpLog::sql("select * from user");
        JwpLog::error(sprintf("REDIS_CONNECT_ERROR redis %s , param[%s] result[%s]",'$name', 'json_encode($arguments)', 'json_encode($ret)'));
        //return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">16载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';

        try {
            // 发生异常的代码段
//            $a=1;
//            $b = 0;
//            $c = $a/ $b;
            return $this->Success('123');
        } catch (Exception $e) {
            echo "捕获到异常1：" . $e->getMessage();
        }
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }

    public function redisTest(){
        $key = '1';
        $red = RedisInstance::set($key,'各级');
        echo $red.'逛街';exit();
//        $redis = new \Redis();
//        $redis->connect();
//        $redis->get("name");
////        $redis->hDel("")
//
//        $redis1 = new RedisDriver("host","port",'auth');
////        $redis2 = new RedisDriver("host2","port2",'auth2');
//        $redis1->get();

        //$re  = new RedisInstance();
            //RedisInstance::
//        RedisInstance::get("name");
//        RedisInstance::set("name","xxxx");
    }
}
